let cancelFullScreen = document.getElementById('cancelFullScreen') //退出全屏按钮
let fullScreen = document.getElementById('fullScreen') //全屏按钮
let fullPage = document.getElementsByTagName('body')[0]
let dom = null
var exitFullscreen = false

window.onresize = function() {
	if (exitFullscreen) {
		exitFullscreen = false
	} else {
		exitFullscreen = true
		fullScreen.style.display = "block"
		cancelFullScreen.style.display = "none"
	}
}

function handleFullScreen() {
	var element = document.documentElement;
	if (exitFullscreen) {
		exitFullscreen = false
		fullScreen.style.display = "block"
		cancelFullScreen.style.display = "none"
		if (document.exitFullscreen) {
			document.exitFullscreen();
		} else if (document.webkitCancelFullScreen) {
			document.webkitCancelFullScreen();
		} else if (document.mozCancelFullScreen) {
			document.mozCancelFullScreen();
		} else if (document.msExitFullscreen) {
			document.msExitFullscreen();
		}
	} else {
		exitFullscreen = true
		fullScreen.style.display = "none"
		cancelFullScreen.style.display = "block"
		if (element.requestFullscreen) {
			element.requestFullscreen();
		} else if (element.webkitRequestFullScreen) {
			element.webkitRequestFullScreen();
		} else if (element.mozRequestFullScreen) {
			element.mozRequestFullScreen();
		} else if (element.msRequestFullscreen) {
			// IE11
			element.msRequestFullscreen();
		}
	}
}
$('.fullscreen').click(function() {
	handleFullScreen()
})
//点击按钮实现全屏
// fullScreen.onclick = function() {
// 	//多浏览器兼容
// 	//moz 火狐浏览器
// 	//webkit 谷歌浏览器 苹果浏览器
// 	// ms ie浏览器

// }
// fullScreen.onclick = function() {
// 	console.log(1111);
// 	console.dir(fullPage)
// 	// moz 火狐浏览器
// 	// webkit 谷歌浏览器 苹果浏览器
// 	// ms ie浏览器
// 	dom = fullPage.requestFullscreen || fullPage.mozRequestFullScreen || fullPage.webkitRequestFullScreen ||
// 		msRequestFullScreen
// 	console.log(dom);
// 	dom.call(fullPage)
// 	if (dom) {
// 		fullScreen.style.display = "none"
// 		cancelFullScreen.style.display = "block"
// 	}
// }
// // 退出全屏事件
// cancelFullScreen.onclick = function() {
// 	// 可以让document退出全屏
// 	let cancelDom = document.cancelFullScreen || document.mozCancelFullScreen || document.webkitCancelFullScreen ||
// 		document.msCancelFullScreen
// 	cancelDom.call(document)

// 	if (cancelDom) {
// 		fullScreen.style.display = "block"
// 		cancelFullScreen.style.display = "none"
// 	}
// }

// keydown
// keyup
// keypress  按下字符键

// 根据窗口大小改变--修改全屏或者取消全屏图标
